package com.muqi.server.common.utilis;

import lombok.Data;

public class UserUtil {
    @Data
    private static class user {
        private Integer id;
        private Integer type;
    }

    private static final ThreadLocal<user> THREAD_LOCAL = new ThreadLocal<>();

    public static void setUser(Integer id, Integer type) {
        user value = new user();
        value.setId(id);
        value.setType(type);
        THREAD_LOCAL.set(value);
    }

    public static Integer getId() {
        return THREAD_LOCAL.get().getId();
    }

    public static Integer getType() {
        return THREAD_LOCAL.get().getType();
    }

    public static void remove() {
        THREAD_LOCAL.remove();
    }
}

